import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)

var routes = [{
    path: '/about',
    name: 'about',
    component: () =>
        import ( /* webpackChunkName: "about" */ '@/views/about.vue')
}]

import Home from '@/views/home/config.js'
routes = routes.concat(Home.routes)
import Settings from '@/views/settings/config.js'
routes = routes.concat(Settings.routes)
import User from '@/views/core/user/config.js'
routes = routes.concat(User.routes)
import CoreApp from '@/views/core/app/config.js'
routes = routes.concat(CoreApp.routes)
import Org from '@/views/core/org/config.js'
routes = routes.concat(Org.routes)
import Car from '@/views/car/config.js'
routes = routes.concat(Car.routes)
import Role from '@/views/core/role/config.js'
routes = routes.concat(Role.routes)
import Metrics from '@/views/core/metrics/config.js'
routes = routes.concat(Metrics.routes)
import ApiDoc from '@/views/dev/config.js'
routes = routes.concat(ApiDoc.routes)
import Bpm from '@/views/bpm/config.js'
routes = routes.concat(Bpm.routes)

// console.debug(routes)
const router = new Router({
    // mode: 'history',
    routes: routes
});

var title = "Enterprise Information Management System - AOS.INK"

router.beforeEach((to, from, next) => {
    console.debug("router.beforeEach", to);
    next();
    if (to.meta !== undefined && to.meta.title !== undefined)
        window.document.title = to.meta.title + " - " + title;
    else
        window.document.title = title;
})

export default router